export const errorMiddleware = (err, req, res, next) => {
    if(err){
        const {name,code} = err;
        let msg = ''
        console.log(err);
        
        if(name === 'MongoServerError'){
            if(code === 11000){
                msg = '值重复'
            }
        }
        // 封装错误函数
        res.json({code: 1, msg})
    }
    next();
}